package nl.boektrust.btsoep.shared.model;

public enum LanguageCode {
	UNDEFINED,DUTCH,ENGLISH,GERMAN,FRENCH,SPANISH,FRYSIAN,
	ARABIC,
	RUSSIAN,
	MULTILINGUAL;
	
	public static String stringValue(LanguageCode t) {
		String value = new String();
		if (t == null) {
			System.err.println("LanguageCode.stringValue() was called with a null argument");
			return "";
		}
		switch (t) {
		case UNDEFINED: value = "Onbekend"; break;
		case DUTCH: value = "Nederlands"; break;
		case ENGLISH: value = "Engels"; break;
		case GERMAN: value = "Duits"; break;
		case FRENCH: value = "Frans"; break;
		case SPANISH: value = "Spaans"; break;
		case FRYSIAN: value = "Fries"; break;
		case ARABIC: value = "Arabisch"; break;
		case RUSSIAN: value = "Russisch"; break;
		case MULTILINGUAL: value = "Meertalig"; break;
		}
		return value;
		
	}
	
	public  String toString() {
		return stringValue(this);
	}
	
	public static String stringValueForOnix(LanguageCode t) {
		String value = new String();
		if (t == null) {
			System.err.println("LanguageCode.stringValueForOnix() was called with a null argument");
			return "";
		}
		switch (t) {
		case UNDEFINED: value = "Onbekend"; break;
		case DUTCH: value = "dut"; break;
		case ENGLISH: value = "eng"; break;
		case GERMAN: value = "ger"; break;
		case FRENCH: value = "fre"; break;
		case SPANISH: value = "spa"; break;
		case FRYSIAN: value = "fry"; break;
		case ARABIC: value = "ara"; break;
		case RUSSIAN: value = "rus"; break;
		case MULTILINGUAL: value = "mul"; break;
		}
		return value;
		
	}
	
	
	public static LanguageCode parseStringIntoLanguageCode(String s) {
		if (s.equals("Nederlands")) return DUTCH;
		if (s.equals("Engels")) return ENGLISH;
		if (s.equals("Duits")) return GERMAN;
		if (s.equals("Frans")) return FRENCH;
		if (s.equals("Spaans")) return SPANISH;
		if (s.equals("Fries")) return FRYSIAN;
		if (s.equals("Arabisch")) return ARABIC;
		if (s.equals("Russisch")) return RUSSIAN;
		if (s.equals("Meertalig")) return MULTILINGUAL;
		return UNDEFINED;
	}
	
	public static LanguageCode parseOnixStringIntoLanguageCode(String s) {
		for (LanguageCode c : LanguageCode.values()) {
			if (LanguageCode.stringValueForOnix(c).equals(s) == true) return c;
		}
		return UNDEFINED;
	}
	

}
